package god.dream.user.model;

import java.sql.Date;

import org.apache.commons.lang.builder.EqualsBuilder;

public class User {
	private int id = 0;
	private String name = null;
	private int age = 0;
	private Date birthDate = null;
	private String phone = null;
	private String cellPhone = null;
	private String depart = null;
	private String career = null;
	private String email = null;
	private String addr = null;
	private String note = null;

	public User() {
	}

	public User(String userId, String userPw, String name, int age) {
		this.name = name;
		this.age = age;
	}

	public User(int id, String userId, String userPw, String name, int age,
			Date birthDate, String phone, String cellPhone, String depart,
			String career, String email, String addr, String note) {
		this.id = id;
		this.name = name;
		this.age = age;
		this.birthDate = birthDate;
		this.phone = phone;
		this.cellPhone = cellPhone;
		this.depart = depart;
		this.career = career;
		this.email = email;
		this.addr = addr;
		this.note = note;
	}

	public Object[] insert() {
		return new Object[] { getId(), getName(), getAge(),
				getBirthDateToDate(), getPhone(), getCellPhone(), getDepart(),
				getCareer(), getEmail(), getAddr(), getNote() };
	}

	public Object[] update() {
		return new Object[] { getName(), getAge(), getBirthDateToDate(), getPhone(), 
				getCellPhone(), getDepart(), getCareer(), getEmail(), getAddr(), 
				getNote(), getId() };
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof User == false) {
			return false;
		}
		if (this == obj) {
			return true;
		}

		User user = (User) obj;
		return new EqualsBuilder()
				.append(getName(), user.getName())
				.append(getAge(), user.getAge())
				.append(getBirthDate(), user.getBirthDate())
				.append(getPhone(), user.getPhone())
				.append(getCellPhone(), user.getCellPhone())
				.append(getDepart(), user.getDepart())
				.append(getCareer(), user.getCareer())
				.append(getEmail(), user.getEmail())
				.append(getAddr(), user.getAddr())
				.append(getNote(), user.getNote())
				.isEquals();
	}
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public Date getBirthDateToDate() {
		return birthDate;
	}
	public String getBirthDate() {
		if(birthDate != null)
			return birthDate.toString();
		else
			return null;
	}

	public void setBirthDate(String birthDate) {
		this.birthDate = Date.valueOf(birthDate);
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getCellPhone() {
		return cellPhone;
	}

	public void setCellPhone(String cellPhone) {
		this.cellPhone = cellPhone;
	}

	public String getDepart() {
		return depart;
	}

	public void setDepart(String depart) {
		this.depart = depart;
	}

	public String getCareer() {
		return career;
	}

	public void setCareer(String career) {
		this.career = career;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public String getAddr() {
		return addr;
	}

	public void setAddr(String addr) {
		this.addr = addr;
	}

}
